"""
Code to plot the Human Rights result figure
"""

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
import warnings
warnings.filterwarnings('ignore')


def main():
    df = pd.read_csv('../results/Human Rights/hr_results.csv')

    df.percentage_features = df.percentage_features*100

    ecc = df[df.algo == 'ECC']
    br = df[df.algo == 'BR']

    sns.set(font_scale=1)
    f, axes = plt.subplots(2, 2, figsize=(19, 12))

    sns.lineplot(
        x="percentage_features", y="Subset Accuracy", data=ecc,
        label='ECC', ax=axes[0, 0])
    sns.lineplot(
        x="percentage_features", y="Subset Accuracy", data=br,
        label='BR', ax=axes[0, 0]).set(
            xlabel='Percentage of features used (%)',
            ylabel='Subset Accuracy in %')
    sns.lineplot(
        x="percentage_features", y="Hamming Loss",
        data=ecc, label='ECC', ax=axes[0, 1])
    sns.lineplot(
        x="percentage_features", y="Hamming Loss",
        data=br, label='BR', ax=axes[0, 1]).set(
        xlabel='Percentage of features used (%)',
        ylabel='Hamming Loss in %')
    sns.lineplot(
        x="percentage_features", y="Ranking Loss",
        data=ecc, label='ECC', ax=axes[1, 1])
    sns.lineplot(
        x="percentage_features", y="Ranking Loss",
        data=br, label='BR', ax=axes[1, 1]).set(
            xlabel='Percentage of features used (%)',
            ylabel='Ranking Loss')
    sns.lineplot(
        x="percentage_features", y="Macro-F1",
        data=ecc, label='ECC F1-macro',
        color='#6782b5', ax=axes[1, 0])
    sns.lineplot(
        x="percentage_features", y="Macro-F1",
        data=br, label='BR F1-macro',
        color='#d89871', ax=axes[1, 0])
    temp = sns.lineplot(
        x="percentage_features", y="Micro-F1",
        data=ecc, label='ECC F1-micro',
        color='#6782b5', ax=axes[1, 0])
    sns.lineplot(
        x="percentage_features", y="Micro-F1",
        data=br, label='BR F1-micro',
        color='#d89871', ax=axes[1, 0]).set(
            xlabel='Percentage of features used (%)', ylabel='F1-Score')
    temp.lines[2].set_linestyle("--")
    temp.lines[3].set_linestyle("--")
    leg = temp.legend()
    leg_lines = leg.get_lines()

    plt.savefig('../plots/figure_2.pdf')
    plt.savefig('../plots/figure_2.png')

if __name__ == "__main__":
    main()
